<script setup>
import { onLaunch, onShow, onHide } from '@dcloudio/uni-app';
import store from '@/store';
import { setPreOptions, touristLoginHandler, checkQueryData } from './hooks';
const props = defineProps({
    shopId: {
        type: [String, Number],
        default: ''
    }
});

/**
 * 记录小程序前后台切换状态，用于计算埋点停留时长
 * @author shipeng_yin@baofu.com
 */
const useAppStatus = store.useAppStatusStore();
const recordAppChangeStatus = () => {
    if (useAppStatus.firstIn === 1) {
        useAppStatus.firstIn = 0;
    }
    useAppStatus.onShow = 1;
};

onLaunch(async options => {
    await touristLoginHandler(options);
});

onShow(options => {
    setPreOptions(options);
    recordAppChangeStatus();
    checkQueryData(options);
});

onHide(() => {
    useAppStatus.onHide = 1;
    useAppStatus.onShow = 0;
    uni.removeStorageSync('inviteMemberId');
    uni.removeStorageSync('channel');
});
</script>

<style lang="scss">
@import 'uview-plus/index.scss';
@import './assets/scss/app.scss';
</style>
